package com.example.yudong;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class Flicker_screen extends AppCompatActivity {

    //闪屏页跳过
    private Button tiaoguo;
    private Handler handler;
    private Runnable runnable;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_flicker_screen);

        tiaoguo = (Button)findViewById(R.id.tiaoguo); //跳过

        //正常情况下不点击跳过
        handler = new Handler();
        handler.postDelayed(runnable = new Runnable() {
            @Override
            public void run() {
                //从闪屏页面跳转到首页
                Intent intent =new Intent(Flicker_screen.this,MainActivity.class);
                startActivity(intent);
                finish();
            }
        },5000); //延迟5秒后发送Handler信息

        tiaoguo.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(Flicker_screen.this,MainActivity.class);
                startActivity(intent);
                finish();
                if (runnable != null){
                    handler.removeCallbacks(runnable);
                }
            }
        });
    }
}